package com.yangcsoft.modules.deptmanage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yangcsoft.common.utils.PageUtils;
import com.yangcsoft.common.utils.Query;

import com.yangcsoft.modules.deptmanage.dao.CustomerInfoDao;
import com.yangcsoft.modules.deptmanage.entity.CustomerInfoEntity;
import com.yangcsoft.modules.deptmanage.service.CustomerInfoService;


@Service("customerInfoService")
public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoDao, CustomerInfoEntity> implements CustomerInfoService {
    @Autowired
    private CustomerInfoDao dao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = params.get("key").toString();
        Page<CustomerInfoEntity> page = this.selectPage(
                new Query<CustomerInfoEntity>(params).getPage(),
                new EntityWrapper<CustomerInfoEntity>()
                                             .like("customer_no",key)
                 .or()
                                                             .like("customer_dept_name",key)
                 .or()
                                                             .like("dept_type",key)
                 .or()
                                                             .like("constract_name",key)
                 .or()
                                                             .like("constract_type",key)
                 .or()
                                                             .like("constract_tel",key)
                 .or()
                                                             .like("constract_email",key)
                 .or()
                                                             .like("constract_wechat",key)
                 .or()
                                                             .like("create_date",key)
                 .or()
                                                             .like("create_user",key)
                 .or()
                                                             .like("update_date",key)
                 .or()
                                                            .like("update_user",key)
                                    );

        return new PageUtils(page);
    }

    @Override
    public void save(CustomerInfoEntity entity) {
        dao.save(entity);
    }


}
